<?php

class ReceiveTempSession {

	private $message = "";
	private $auth = null;
	private $cp = null;
	function ReceiveTempSession() {
		$this->blacklist = new Blacklist();
		if ($this->blacklist->isInBlacklist()) {
			$this->flag = false;
			return;
		}
	}
	
//	public function run() {
//		if(!isset($_SESSION['tem_num'])) {
//			$_SESSION['tem_num'] = 1;
//			$this->message = "暂时不提供临时会话服务、、╮(╯▽╰)╭";
//			return;
//		}
//		if($_SESSION['tem_num']==1) {
//			$this->message = "说了不提供服务的啦╮(╯▽╰)╭";
//			
//		}else if($_SESSION['tem_num']==2){
//			$this->message = "不管你说什么我都不会回答的= =";
//		}else if($_SESSION['tem_num']==3) {
//			$this->message = "好吧,再见。。";
//		}else{
//			return;
//		}
//		$_SESSION['tem_num']=$_SESSION['tem_num']+1;
//		
//	}
	
public function run() {
	//echo "测试1";
//		if (!$this->flag)
//			return;
	//echo "测试2";			
		if (!isset ($_SESSION['NOWMODE'])) {
			if (@ preg_match('/^\/(\S+)\s*(.*)$/is', trim($_POST[Message]), $m)) {
				$class = $this->getFunByKey($m[1]);
				if($class!="") {
					$_SESSION['NOWMODE']=$class;
					$modelfile = ROOT_PATH . "Lib/Mode/{$class}.class.php";
					require_once ("{$modelfile}");
					$do = new $class;
					$do->run();
					$this->message = $do->message;
				}
			}else {
				//$modelfile = ROOT_PATH . "Lib/Mode/Teach.class.php";
				//require_once ("{$modelfile}");
				//$do = new Teach();
				//$do->getTeachWord();
				//$this->message = $do->message;
				
			}
		} else {
			$class = $_SESSION['NOWMODE'];
			$modelfile = ROOT_PATH . "Lib/Mode/{$class}.class.php";
			require_once ("{$modelfile}");
			$do = new $class;
			$do->run();
			$this->message = $do->message;
		}
	}

	private function getFunByKey($key) {
		$ret2 = @ DB :: LimitQuery('td_mode_function', array (
			'condition' => array (
				'key' => $key
			)
		), false);
		if ($ret2)
			return $ret2[0][funname];
		else
			return "";
	}
	private function __get($property_name) {
		return $this-> $property_name;
	}

	private function __set($property_name, $value) {
		$this->$property_name = $value;
	}
}
?>